package com.woniu.car.common;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

/*
   BeanUtil的工具类复制集合
 */
public class BeanCopyUtils extends BeanUtils {
    public static <S,T> List<T> copyList(List<S> sources, Supplier<T> target){
        ArrayList<T> al = new ArrayList<T>();
        for(S source:sources){
            T t = target.get();
            BeanUtils.copyProperties(source,t);
            al.add(t);
        }
        return al;
    }
}
